#include <stdio.h>
#include "CDirectories.h"

static char* g_lpszPossiblePaths[]		=	{
	"C:\\Program Files\\Wonderland Online\\"				,
	"C:\\Program Files (x86)\\Wonderland Online\\"			,
	NULL
} ;

static char* g_lpszPossibleDataPaths[]	=	{
	"C:\\Program Files\\Wonderland Online\\data\\"			,
	"C:\\Program Files (x86)\\Wonderland Online\\data\\"	,
	NULL
} ;

static int g_nPath = -1 ;


BOOL CDirectories::Initialize(void)
{
	int			n		;
	DWORD		ftyp	;

	n = 0 ;

	
	while(NULL != g_lpszPossiblePaths[n]) {
		ftyp = GetFileAttributes(g_lpszPossiblePaths[n]);
		if(INVALID_FILE_ATTRIBUTES != ftyp && (ftyp & FILE_ATTRIBUTE_DIRECTORY)) {
			ftyp = GetFileAttributes(g_lpszPossibleDataPaths[n]);
			if(INVALID_FILE_ATTRIBUTES != ftyp && (ftyp & FILE_ATTRIBUTE_DIRECTORY)) {
				g_nPath = n;
				break;
			}
		}
		++n;
	}

	return (-1 != g_nPath);
}

char* CDirectories::GetWLDirectory(void) const
{
	if(-1 != g_nPath)
		return g_lpszPossiblePaths[g_nPath];

	return NULL;
}

char* CDirectories::GetWLDataDirectory(void) const
{
	if(-1 != g_nPath)
		return g_lpszPossibleDataPaths[g_nPath];

	return NULL;
}

void CDirectories::Uninitialize(void)
{ }

